// stdx/threadx.rs
// CRITICAL: 线程示例（spawn, join, builder）。
// AUTO_COMMENT: 展示共享数据的基本用法。

#[allow(dead_code)]
pub fn stdx_examples_threadx() {
    use std::sync::{Arc, Mutex};
    use std::thread;
    let counter = Arc::new(Mutex::new(0));
    let c = Arc::clone(&counter);
    let handle = thread::spawn(move || {
        let mut num = c.lock().unwrap();
        *num += 1;
    });
    let _ = handle.join();
    let _ = *counter.lock().unwrap();
}
